package ru.stepuk.modern.generators;

/**
 *
 * @author ivan
 */
public class MultiplicativeGenerator implements RandomNumberGenerator {

    private static final int A = 630360016;
    private static final int M = 2147483647;
    private double previous;
    private int seed;

    public MultiplicativeGenerator(int seed) {
        setSeed(seed);
    }

    public double nextValue() {
        previous = (A * previous) % M;
        return previous / M;
    }

    public int getSeed() {
        return seed;
    }

    public void setSeed(int seed) {
        this.previous = this.seed = seed;
    }
}
